#!/bin/bash
date

a=$(cat /proc/meminfo|grep "MemTotal"|awk '{print $2/1024/1024}')
b=$(cat /proc/meminfo|grep -E "MemTotal|MemFree|^Cached|Buffers|SReclaimable"|awk '/MemTotal/{mt=$2}/MemFree/{mf=$2}/Cached/{c=$2}/Buffers/{b=$2}/SReclaimable/{sr=$2}; END {print (mt-mf-c-b-sr)/1024/1024}')
c=$(cat /proc/meminfo|grep -E "^Cached|Buffers|SReclaimable"|awk '/Cached/{c=$2}/Buffers/{b=$2}/SReclaimable/{sr=$2}; END {print (c+b+sr)/1024/1024}')
d=$(cat /proc/meminfo|grep -E "MemFree"|awk '/MemFree/{mf=$2}; END {print (mf)/1024/1024}')
e=$(cat /proc/meminfo|grep -E "SwapTotal|SwapFree"|awk '/SwapTotal/{st=$2}/SwapFree/{sf=$2}; END {print (st-sf)/1024}')

echo "RAM Total: $a"
echo "RAM Used: $b"
echo "RAM Cache + Buffer: $c"
echo "RAM Free: $d"
echo "SWAP Used: $e"
